package org.example.myframework.frame.demo.controller;

import org.example.myframework.frame.common.redis.utils.CacheUtil;
import org.example.myframework.frame.demo.service.biz.BizRedisService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/redisOperation")
public class RedisController {

    @Resource
    private BizRedisService bizRedisService;

    @Resource
    private CacheUtil cacheUtil;

    @GetMapping("/testLocalCache")
    public void testLocalCache() throws Exception {
        List<Long> skuIds = new ArrayList<>();
        cacheUtil.getResult(skuIds, "skuInfo.skuName", SkuInfo.class, (list) -> {
            Map<Long, SkuInfo> skuInfoMap = getSkuName((List<Long>) list);
            return skuInfoMap;
        });
    }

    public Map<Long, SkuInfo> getSkuName(List<Long> skuIds) {
        return Collections.emptyMap();
    }

    public Map<Long, SkuPriceInfo> getSkuPrice(List<Long> skuIds) {
        return Collections.emptyMap();
    }

    class SkuInfo {
        private Long id;
        private String name;
        private Long price;
    }

    class SkuPriceInfo {
        private Long id;
        private String name;
        private Long price;
    }


}
